/*
 * Copyright (C) 2017-2021
 * All rights reserved, Designed By 深圳中科鑫智科技有限公司
 * Copyright authorization contact 18814114118
 */
package com.shop.cereshop.admin.service.versions.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shop.cereshop.admin.dao.versions.AppVersionsDAO;
import com.shop.cereshop.admin.dao.versions.CereAgreementDAO;
import com.shop.cereshop.commons.domain.common.Page;
import com.shop.cereshop.commons.domain.versions.AppVersions;
import com.shop.cereshop.admin.service.versions.AppVersionsService;

import com.shop.cereshop.commons.domain.versions.CereAgreement;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 业务实现类
 * 多端应用版本管理表
 * </p>
 *
 * @author
 * @date 2025-08-02
 */
@Slf4j
@Service
public class AppVersionsServiceImpl extends ServiceImpl<AppVersionsDAO, AppVersions> implements AppVersionsService {
    @Autowired
    private AppVersionsDAO appVersionsDAO;


    @Autowired
    private CereAgreementDAO cereAgreementDAO;

    @Override
    public CereAgreement getById(Long id) {
        return cereAgreementDAO.selectById(id);
    }

    @Override
    public Page<AppVersions> getPage(Integer pageNum, Integer pageSize,String verSionType,Long appId) {
        PageHelper.startPage(pageNum, pageSize);
        List<AppVersions> appVersions = appVersionsDAO.selectPageByIdOrName(verSionType,appId);
        PageInfo<AppVersions> appVersionsPageInfo = new PageInfo<>(appVersions);
        Page<AppVersions> appVersionsPage = new Page<>(appVersionsPageInfo.getList(), appVersionsPageInfo.getTotal());
        return appVersionsPage;
    }

    @Override
    public Integer insertAppInfo(AppVersions appVersions) {
        if (appVersionsDAO.insertAppInfo(appVersions) > 0) {
            return 1;
        }
        return 0;
    }

    @Override
    public Integer updateAppinfo(AppVersions appVersions) {
        if (appVersionsDAO.updateAppInfo(appVersions) > 0) {
            return 1;
        }
        return 0;
    }


}
